package me.shiqiang.im.action;

import com.tst.common.returnobj.BaseReturnObj;
import com.tst.common.returnobj.ReturnObj;
import com.tst.common.returnobj.ReturnObjCode;
import me.shiqiang.im.domain.ClientVersion;
import me.shiqiang.im.service.ClientVersionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by John on 2018/5/18
 */
@RestController
@RequestMapping("im/clientVersion")
public class ClientVersionAction {
    @Autowired
    ClientVersionService service;

    @PutMapping("/{version}/{forceUpdate}")
    public BaseReturnObj changeClientVersion(@PathVariable String version, @PathVariable int forceUpdate) {
        service.changeClientVersion(version, forceUpdate);
        return new BaseReturnObj(ReturnObjCode.SUCCESS,"变更成功");
    }

    @GetMapping
    public ReturnObj<ClientVersion> getClientVersion() {
        ClientVersion result = service.getClientVersion();
        return new ReturnObj<>(ReturnObjCode.SUCCESS,result);
    }
}
